<template>
  <el-dialog :title="title"
             :close-on-click-modal="false"
             :visible.sync="addOrEditShow"
             width="480px"
             :before-close="handleClose">
    <el-form :model="dialogForm"
             ref="dialogForm"
             :rules="rules"
             label-width="100px">
      <el-form-item label="房间号："
                    prop="name">
        <el-input v-model="dialogForm.name"
                  type="number"
                  size="small"
                  placeholder="请输入房间号"></el-input>
      </el-form-item>
      <el-form-item label="所在楼层："
                    prop="floorId">
        <el-select v-model="dialogForm.floorId"
                   size="small"
                   style="width: 100%;"
                   placeholder="请选择">
          <el-option v-for="item in floorList"
                     :key="item.id"
                     :label="item.name"
                     :value="item.id">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="床位数量："
                    prop="bedNum">
        <el-input v-model="dialogForm.bedNum"
                  type="number"
                  size="small"
                  placeholder="请输入床位数量"></el-input>
      </el-form-item>
    </el-form>
    <span slot="footer"
          class="dialog-footer">
      <el-button @click="handleClose"
                 size="small">取 消</el-button>
      <el-button type="primary"
                 @click="addOrEditSure"
                 size="small">确 定</el-button>
    </span>
  </el-dialog>
</template>
<script>
export default {
  props: {
    addOrEditShow: Boolean,
    dialogForm: Object,
    floorList: Array,
    addOrEditSure: Function,
    title: String,
    rules: Object
  },
  methods: {
    handleClose () {
      this.$refs.dialogForm.resetFields()
      this.$emit('handleClose')
    }
  }
}
</script>
